#ifdef _WIN32

#endif
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <list>
#include <bitset>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <ctime>
#include <numeric>
#include <functional>
#include <valarray>
#include <complex>
using namespace std;

const int dx[]={0,-1,0,1,-1,1, 1,-1};
const int dy[]={1,0,-1,0, 1,1,-1,-1};
const double eps=1e-8;

typedef long long LL;

typedef pair<int,int> pii;
typedef vector<int> vi;

#define sz(a) a.size()
#define fori(i,a,b) for(int i(a),_b(b);i<=_b;++i)

#define forn(i,n) fori(i,0,n-1)

#define all(a) a.begin(),a.end()

#define two(X) (1LL<<(X))

#define sqr(a) ((a)*(a))

class FoxPlayingGame {
double Pow(double a, int b)
{
	if (b==0) return 1;
	double tmp=Pow(a,b/2);
	if ((b&1)==1) return sqr(tmp)*a;
	return sqr(tmp);
}
public:
	double theMax(int nA, int nB, int paramA, int paramB) {
		double qa=paramA/1000.0;
		double qb=paramB/1000.0;
        if (qa<eps && qb<eps && nB>0)
        {
            qa*=qb;
            nB--;
        }
        bool OddnB=(nB&1)==1;
		bool between01qb=(abs(qb)>eps && abs(qb)+eps<1);

        if (nB>0 && ((qa>eps && qb<eps && OddnB) || (qa<eps && qb<eps && !OddnB))) nB--;
        if (abs(qb)<=eps || ((between01qb && qa>eps) || (qa<eps && qb>eps && !between01qb))) nB=0;
        return qa*nA*Pow(abs(qb),nB);
	}
};



// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit-pf 2.3.0
#include <iostream>
#include <string>
#include <vector>
#include <ctime>
#include <cmath>
using namespace std;
bool KawigiEdit_RunTest(int testNum, int p0, int p1, int p2, int p3, bool hasAnswer, double p4) {
	cout << "Test " << testNum << ": [" << p0 << "," << p1 << "," << p2 << "," << p3;
	cout << "]" << endl;
	FoxPlayingGame *obj;
	double answer;
	obj = new FoxPlayingGame();
	clock_t startTime = clock();
	answer = obj->theMax(p0, p1, p2, p3);
	clock_t endTime = clock();
	delete obj;
	bool res;
	res = true;
	cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl;
	if (hasAnswer) {
		cout << "Desired answer:" << endl;
		cout << "\t" << p4 << endl;
	}
	cout << "Your answer:" << endl;
	cout << "\t" << answer << endl;
	if (hasAnswer) {
		res = answer == answer && fabs(p4 - answer) <= 1e-9 * max(1.0, fabs(p4));
	}
	if (!res) {
		cout << "DOESN'T MATCH!!!!" << endl;
	} else if (double(endTime - startTime) / CLOCKS_PER_SEC >= 2) {
		cout << "FAIL the timeout" << endl;
		res = false;
	} else if (hasAnswer) {
		cout << "Match :-)" << endl;
	} else {
		cout << "OK, but is it right?" << endl;
	}
	cout << "" << endl;
	return res;
}
int main() {
	bool all_right;
	bool disabled;
	bool tests_disabled;
	all_right = true;
	tests_disabled = false;
	
	int p0;
	int p1;
	int p2;
	int p3;
	double p4;
	
	{
	// ----- test 0 -----
	disabled = false;
	p0 = 5;
	p1 = 4;
	p2 = 3000;
	p3 = 2000;
	p4 = 240.0;
	all_right = (disabled || KawigiEdit_RunTest(0, p0, p1, p2, p3, true, p4) ) && all_right;
	tests_disabled = tests_disabled || disabled;
	// ------------------
	}
	
	{
	// ----- test 1 -----
	disabled = false;
	p0 = 3;
	p1 = 3;
	p2 = 2000;
	p3 = 100;
	p4 = 6.0;
	all_right = (disabled || KawigiEdit_RunTest(1, p0, p1, p2, p3, true, p4) ) && all_right;
	tests_disabled = tests_disabled || disabled;
	// ------------------
	}
	
	{
	// ----- test 2 -----
	disabled = false;
	p0 = 4;
	p1 = 3;
	p2 = -2000;
	p3 = 2000;
	p4 = -8.0;
	all_right = (disabled || KawigiEdit_RunTest(2, p0, p1, p2, p3, true, p4) ) && all_right;
	tests_disabled = tests_disabled || disabled;
	// ------------------
	}
	
	{
	// ----- test 3 -----
	disabled = false;
	p0 = 5;
	p1 = 5;
	p2 = 2000;
	p3 = -2000;
	p4 = 160.0;
	all_right = (disabled || KawigiEdit_RunTest(3, p0, p1, p2, p3, true, p4) ) && all_right;
	tests_disabled = tests_disabled || disabled;
	// ------------------
	}
	
	{
	// ----- test 4 -----
	disabled = false;
	p0 = 50;
	p1 = 50;
	p2 = 10000;
	p3 = 2000;
	p4 = 5.62949953421312E17;
	all_right = (disabled || KawigiEdit_RunTest(4, p0, p1, p2, p3, true, p4) ) && all_right;
	tests_disabled = tests_disabled || disabled;
	// ------------------
	}
	
	{
	// ----- test 5 -----
	disabled = false;
	p0 = 41;
	p1 = 34;
	p2 = 9876;
	p3 = -1234;
	p4 = 515323.9982341775;
	all_right = (disabled || KawigiEdit_RunTest(5, p0, p1, p2, p3, true, p4) ) && all_right;
	tests_disabled = tests_disabled || disabled;
	// ------------------
	}
	
	if (all_right) {
		if (tests_disabled) {
			cout << "You're a stud (but some test cases were disabled)!" << endl;
		} else {
			cout << "You're a stud (at least on given cases)!" << endl;
		}
	} else {
		cout << "Some of the test cases had errors." << endl;
	}
	return 0;
}
// END KAWIGIEDIT TESTING//Powered by KawigiEdit-pf 2.3.0
//With unused code cleaner (beta) by ahmed_aly
